﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace MethodWorx.CMS.Workflow.Validate
{
    [Serializable]
    public class ValidateConfiguration : IWorkflowConfiguration
    {
        [Required]
        public string FieldName { get; set; }
        public string CompareWith { get; set; }
        public string ComparisonOption { get; set; }
        public bool Required { get; set; }
        public string RegularExpression { get; set; }
        public int? MaximumLength { get; set; }
        public int? MinimumLength { get; set; }
        public string ErrorMessage { get; set; }

        #region IWorkflowConfiguration Members

        public string GetDescriptionSummary()
        {
            string s = this.FieldName;

            if (this.Required)
                s += ", Required";

            if (!string.IsNullOrEmpty(this.RegularExpression))
                s += ", Regular Expression";

            if (this.MaximumLength.HasValue || this.MinimumLength.HasValue)
                s += ", Length Range";

            if(!string.IsNullOrEmpty(this.CompareWith))
            {
                s += " " + (this.ComparisonOption ?? "") + " " + this.CompareWith;
            }

            return s;
        }

        #endregion
    }
}
